package com.itany.corejava.day04;

import java.util.Arrays;

/*
    动态数组

    java中没有动态数组
    实际动态数组相当于数组的拷贝
    扩展的是
    改变变量的引用
 */
public class Test9 {

    public static void main(String[] args) {


        char[] c={'a','b'};

        System.out.println("c.length = " + c.length);//2

        System.out.println("c = " + Arrays.toString(c));//[a,b]

//        System.out.println(c[2]);




        char[] temp=new char[c.length+1];

//        for (int i = 0; i < c.length; i++) {
//            temp[i]=c[i];
//        }
        System.arraycopy(c,0,temp,0,c.length);

        c=temp;







        c[2]='c';

        System.out.println("c.length = " + c.length);//3

        System.out.println("c = " + Arrays.toString(c));//[a,b,c]


        System.out.println("c = " + c);
        System.out.println("temp = " + temp);

        System.out.println(temp[2]);


    }
}
